package com.lanren.familybookapp.ui.me.presenter;

import com.lanren.common.base.impl.BasePresenter;
import com.lanren.familybookapp.ui.me.interfaces.IMeModel;
import com.lanren.familybookapp.ui.me.model.MeModel;

/**
 * @ClassName MePresenter
 * @Description TODO
 * @Author chongheng.wang
 * @Date 2019/10/5 17:02
 * @Version 1.0
 */
public class MePresenter extends BasePresenter<IMeModel.IMeView> {
    private MeModel meModel;

    public MePresenter() {
        meModel = new MeModel();
    }

    public void getUserInfo() {
        mRootView.showLoading();
        meModel.getUserInfo(new IMeModel.MeModel() {
            @Override
            public void onError(int code, String data) {
                mRootView.showComplete();
                mRootView.showError(code, data);
            }

            @Override
            public void onSuccess() {
                mRootView.showComplete();
                mRootView.onSuccess();
            }
        });
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (meModel != null) {
            meModel.clearDisposable();
            meModel = null;
        }
    }
}
